package com.siwei.mes.entity.experiment.concreteAdmixture;

import com.alibaba.fastjson.JSONObject;
import com.siwei.mes.common.util.JsonUtils;
import com.siwei.mes.entity.experiment.slag.SlagSsl;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @Description: 外加剂-塌落度1h经时变化量
 * @Version: 1.0
 * @author: YANGKE
 * @date: 2024/07/24 17:29
 */
@Data
@Accessors(chain = true)
public class ConcreteAdmixtureTld1hjsbhl {
    @ApiModelProperty(value = "检测日期")
    private String jcrq = "";
    @ApiModelProperty(value = "基准混凝土信息")
    private ConcreteAdmixtureTld1hjsbhl.JzhntObject jzhntObject = new ConcreteAdmixtureTld1hjsbhl.JzhntObject();
    @ApiModelProperty(value = "受检混凝土信息")
    private ConcreteAdmixtureTld1hjsbhl.SjhntObject sjhntObject = new ConcreteAdmixtureTld1hjsbhl.SjhntObject();

    @Data
    @Accessors(chain = true)
    @ApiModel("基准混凝土信息")
    public static class JzhntObject {
        @ApiModelProperty(value = "坍落度信息")
        private List<HntList> jzhntList = Collections.singletonList(new HntList());
        @ApiModelProperty(value = "1h变化量平均值")
        private String h1bhlpjz = "";
        @ApiModelProperty(value = "坍落度平均值")
        private String tldpjz = "";
        @ApiModelProperty(value = "1小时后坍落度平均值")
        private String h1htldpjz = "";
    }

    @Data
    @Accessors(chain = true)
    @ApiModel("受检混凝土信息")
    public static class SjhntObject {
        @ApiModelProperty(value = "坍落度信息")
        private List<HntList> sjhntList = Collections.singletonList(new HntList());
        @ApiModelProperty(value = "1h变化量平均值")
        private String h1bhlpjz = "";
        @ApiModelProperty(value = "坍落度平均值")
        private String tldpjz = "";
        @ApiModelProperty(value = "1小时后坍落度平均值")
        private String h1htldpjz = "";

    }

    @Data
    @Accessors(chain = true)
    @ApiModel("坍落度信息")
    public static class HntList {
        @ApiModelProperty(value = "坍落度")
        private String tld = "";
        @ApiModelProperty(value = "1h后坍落度")
        private String h1htld = "";
        @ApiModelProperty(value = "1h后变化量")
        private String h1bhl = "";
    }
    /**
     * 字符串转成对象 然后再转成json
     *
     * @param object
     * @return
     */
    private static JSONObject toJsonObject(Object object) {
        ConcreteAdmixtureTld1hjsbhl entity = new ConcreteAdmixtureTld1hjsbhl();
        if (object == null) {
            return JsonUtils.beanToObject(entity);
        }
        if (object instanceof String) {
            entity = JsonUtils.getObject((String) object, ConcreteAdmixtureTld1hjsbhl.class);
        } else if (object instanceof JSONObject) {
            entity = JsonUtils.getObject((JSONObject) object, ConcreteAdmixtureTld1hjsbhl.class);
        }
        return JsonUtils.beanToObject(entity);
    }

    public static String checkIsMust(JSONObject objJson, String name) {
        if (objJson.isEmpty()) {
            return null;
        }
        ConcreteAdmixtureTld1hjsbhl entity = JsonUtils.getObject(objJson, ConcreteAdmixtureTld1hjsbhl.class);
        if (entity == null) {
            return "存在必检项(" + name + ")未检测，请先检测！";
        }
        return null;
    }

    public static void setValue(ConcreteAdmixtureTld1hjsbhl entity, Map<String, Object> data) {

    }
}
